
import { useLocation } from "react-router-dom"

function useQuery() {
    const { search } = useLocation();
    return  new URLSearchParams(search)
  }


function Cinfo(){
    const q= useQuery();
    console.log(q.get('id'))
    return (
        <div>分类详细信息</div>
    )
}

export default Cinfo

/**
 * <Link to="/地址?参数=值&参数=值"
 * 
 * <Route path="/地址"
 * 
 * 获取参数
 * import { useLocation } from "react-router-dom"
 *  const { search } = useLocation(); // ?参数=值&参数=值
 * const s= new URLSearchParams(search);
 * s.get('参数’)
 * 
 * 
 * 
 */


/*
import React, { Component } from 'react'
import {useParams,useLocation,useNavigate}  from "react-router-dom"

function withRouter(Component) {
    return (props) => (
      <Component
        {...props}
        params={useParams()}
        location={useLocation()}
        navigate={useNavigate()}
      />
    );
  }



class Cinfo extends Component {

  render() {
    console.log(this.props.location.search)

    let s= new URLSearchParams(this.props.location.search);
        console.log(s.get('id'))
    return (
      <div>Cinfo</div>
    )
  }
}

export default  withRouter(Cinfo)

*/